<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <include file="Public:jquery" />
        <include file="Public:startapp" />
        <include file="Public:startmoo" />
    </head>
    <body>
        <include file="Public:header" />
        
        <div class="layout">
            
            <include file="Public:position" />
            
            <table class="warp" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="sidebar" valign="top">
                        <include file="Public:sidebar" />
                    </td>
                    <td class="contents" valign="top">
                        
                        <div class="button">
				    		<a href="{:U('add?tag='.$_GET['tag'])}" class="default_button" id="add_archives"><span></span>发布文档/文章</a>
				    	</div>
	                    
                        <div class="a_table">
					    	<table width="100%" cellspacing="1" class="gr_list">
							  <tr class="row" >
							    <th height="20" align="center" >文件名</td>
							    <th align="center" >备份时间</td>
							    <th align="center" >文件大小</td>
							    <th align="center" >管理选项</td>
							  </tr>
							  <php>
							function MyScandir($FilePath='./',$Order=0){
							$FilePath = opendir($FilePath);
							while (false !== ($filename = readdir($FilePath))) {
							  $FileAndFolderAyy[] = $filename;
							}
							$Order == 0 ? sort($FileAndFolderAyy) : rsort($FileAndFolderAyy);
							return $FileAndFolderAyy;
							}
							
							$FileArr = MyScandir('./backup/');
							foreach ($FileArr as $i => $n){
							        if($n != 'PHPMyAdminInitialData.sql' && $i>1){
							                $FileTime = date('Y-m-d H:i:s',filemtime('./backup/'.$n));
							                $FileSize = filesize('./backup/' . $n)/1024;
							
							                if ($FileSize < 1024){
							                        $FileSize = number_format($FileSize,2) . ' KB';
							                } else {
							                        $FileSize = '<font color="#FF0000">' . number_format($FileSize/1024,2) . '</font> MB';
							                }
							                $sAS = "<a href=\"" . U('index',array('action'=>'download','file'=>$n)) . "\">下载</a> | ";
							                $sAS .= "<a onClick=\"return confirm('确定将数据库还原到当前备份吗？');\" href=\"" . U('index',array('tag'=>$_GET['tag'],'action'=>'reduction','file'=>$n)) . "\">还原</a> | ";
							                $sAS .= "<a onClick=\"return confirm('确定删除该备份文件吗？');\" href=\"" . U('index',array('tag'=>$_GET['tag'],'action'=>'del','file'=>$n)) . "\">删除</a>";
							                echo "<tr class=\"row\">
							                <td height=\"20\" align=\"center\">$n</td>
							                <td align=\"center\">$FileTime</td>
							                <td align=\"center\">$FileSize</td>
							                <td align=\"center\">$sAS</td>
							                </tr>";
							                unset($FileTime,$FileSize,$sAS);
							        }
							}
							</php>
							  <tr class="row">
							    <td colspan="4" height="40" align="center"><input type="button" value="备份数据库" style="width:120px; height:28px;cursor: hand" onClick="javascript:location.href='{:U('index',array('tag'=>$_GET['tag'],'action'=>'backup'))}'"></td>
							  </tr>
							  <tr><td height="5" colspan="4" class="bottomTd"></td></tr>
							</table>
							<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
							        <tr class="row">
							                <td style="color:#333333; line-height:20px;">
							                        注：1、本操作只对数据库中当前网站数据(表前缀为 "{:C('DB_PREFIX')}" 的表)进行备份。如果您的数据库中有多个网站，其它站点不受影响。<br />
							                        　　2、备份后的数据可以进行还原操作或通过 phpMyAdmin 导入。
							                </td>
							        </tr>
							</table>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        
        <include file="Public:footer" />
    </body>
</html>